package it.polimi.travelDream.web.beans;

import it.polimi.it.TravelDream.ejb.UserMgr;
import it.polimi.it.TravelDream.ejb.eaos.UserDTO;

import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 * Session Bean implementation class ModifyUser
 */
@ManagedBean(name="modifyUser")
@RequestScoped
public class ModifyUser {

	@EJB
	private UserMgr userMgr;

	private UserDTO user;
	
	//restituisce un oggetto UserDTO
	public UserDTO getUser() {
		return user;
	}

	public void setUser(UserDTO user) {
		this.user = user;
	}
	
	//chiama userMgr.save e gli passa l'oggetto DTO.
	


    public ModifyUser(){
    		 user = new UserDTO();
    		}
        
    public  void saveUserChanges(){
		user.setEmail(userMgr.getUserDTO().getEmail());
		System.out.println(user.getEmail());
		System.out.println(user.getFirstName());
		System.out.println(user.getLastName());
		System.out.println(user.getPassword());
		userMgr.update(user);
	}

}
